﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Diagnostics;

namespace Barbar.UrlGuard.BL.Concrete
{
    internal class BrowserProvider : IBrowserProvider
    {
        private string m_BrowserDefaultPath;

        #region IBrowserProvider Members

        public void OpenUrl(string url)
        {
            if (string.IsNullOrEmpty(url))
                throw new ArgumentNullException("url");

            if (m_BrowserDefaultPath == null)
            {
                string key = @"htmlfile\shell\open\command";
                RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(key, false);
                m_BrowserDefaultPath = ((string)registryKey.GetValue(null, null)).Split('"')[1];
            }
            Process.Start(m_BrowserDefaultPath, url);
        }

        #endregion
    }
}
